//
//  CustomCollectionViewCell.m
//  CustomUICollectionView
//
//  Created by jyLiu on 2016/12/5.
//  Copyright © 2016年 JY_L. All rights reserved.
//

#import "CustomCollectionViewCell.h"

@implementation CustomCollectionViewCell
- (id)initWithFrame:(CGRect)frame
{
    if ([super initWithFrame:frame]) {
        [self awakeFromNib];
    }
    
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    UIImageView* icon=[[UIImageView alloc] init];
//    [icon setImage:[UIImage imageNamed:@"audit_tongyong"]];
    [self.contentView addSubview:icon];
    _icon=icon;
    
    UIButton* a=[[UIButton alloc] init];
    [a setTitle:@"tt" forState:UIControlStateNormal];
    [a setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    a.backgroundColor=[UIColor whiteColor];
    [self.contentView addSubview:a];
//    [a setTag:indexPath.row];
    //去掉按钮点击事件，现在这里没有test方法了
//    [a addTarget:self action:@selector(test:) forControlEvents:UIControlEventTouchUpInside];
    _a=a;
    
    UILabel* step=[[UILabel alloc] init];
    step.textColor = [UIColor xm_colorFromRGB:0x858C96];
    step.font = [UIFont xm_font:13.0];
    step.text=@"20/20";
    
    [self.contentView addSubview:step];
    _step=step;
    
    UIButton* dangqian=[[UIButton alloc] init];
    [dangqian setTitle:@"当前的分: 85" forState:UIControlStateNormal];
    [dangqian setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    dangqian.titleLabel.font=[UIFont xm_font:13.0];
    dangqian.backgroundColor=[UIColor lightGrayColor];
    dangqian.layer.cornerRadius=10;
    [self.contentView addSubview:dangqian];
    _dangqian=dangqian;
    
    UIView* line=[[UIView alloc] init];
    line.backgroundColor=[UIColor redColor];
    [self.contentView addSubview:line];
    
    UILabel* score=[[UILabel alloc] init];
    [score setBackgroundColor:[UIColor clearColor]];
    [score setText:@"84.5%"];
    score.font = [UIFont xm_medium:25.0];
    score.numberOfLines = 1;
    score.textColor = [UIColor xm_jetblackColor];
    score.textAlignment=UITextAlignmentCenter;
    [self.contentView addSubview:score];
    score.hidden=YES;
    _score=score;
    
    [icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self).offset(0);
        make.top.equalTo(self).offset(10);
        make.width.height.equalTo(@70);
    }];
    
    [a mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self).offset(0);
        make.top.equalTo(icon.mas_bottom).offset(3);
        
    }];
    
    [step mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(a.mas_bottom).offset(5);
        
    }];
    
    [dangqian mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(a.mas_bottom).offset(3);
        //        make.centerY.equalTo(step).offset(0);
        make.height.equalTo(@20);
        
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self).offset(-0.5);
        make.height.mas_equalTo(@0.5);
        make.width.mas_equalTo(self);
    }];
    
    [score mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self).offset(0);
        make.top.mas_equalTo(self).offset(30);
        make.width.mas_equalTo(@100);
    }];
}

@end
